import request from '@/utils/request'

// 获取spu图片
const getSpuImageList = (spuId) => {
  return request({
    url: `/admin/product/spuImageList/${spuId}`
  })
}

// 获取销售属性
const getSpuSaleAttrList = (spuId) => {
  return request({
    url: `/admin/product/spuSaleAttrList/${spuId}`
  })
}

// 获取商品详情
const getAttrInfoList = (obj) => {
  return request({
    url: `/admin/product/attrInfoList/${obj.selectionOne}/${obj.selectionTwo}/${obj.selectionThree}`
  })
}

// 保存sku信息
const saveSkuInfo = (data) => {
  return request({
    url: `/admin/product/saveSkuInfo`,
    method: 'post',
    data
  })
}

// 获取sku列表数据的接口
const findBySpuId = (spuId) => {
  return request({
    url: `/admin/product/findBySpuId/${spuId}`
  })
}

// 获取sku列表信息
const getSkuList = (page, limit) => {
  return request({
    url: `/admin/product/list/${page}/${limit}`
  })
}

// 上架
const onSale = (skuId) => {
  return request({
    url: `/admin/product/onSale/${skuId}`
  })
}

// 下架
const cancelSale = (skuId) => {
  return request({
    url: `/admin/product/cancelSale/${skuId}`
  })
}

// 获取sku详情
const getSkuById = (skuId) => {
  return request({
    url: `/admin/product/getSkuById/${skuId}`
  })
}

export {
  getSpuImageList,
  getSpuSaleAttrList,
  getAttrInfoList,
  saveSkuInfo,
  findBySpuId,
  getSkuList,
  onSale,
  cancelSale,
  getSkuById
}
